//
//  ReadCell.m
//  New
//
//  Created by 才诗琦 on 16/1/21.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "ReadCell.h"

@implementation ReadCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imagView = [[UIImageView alloc] init];
        _imagView.layer.cornerRadius = 5;
        _imagView.clipsToBounds = YES;
        [self.contentView addSubview:_imagView];
        [_imagView release];
        
        
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:18];
        [self.contentView addSubview: _titleLabel];
        [_titleLabel release];
        //描述
        self.digestLabel = [[UILabel alloc] init];
        _digestLabel.numberOfLines = 0;
        
        _digestLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_digestLabel];
        [_digestLabel release];
        
        self.replayCount = [[UILabel alloc] init];;
        [self.contentView addSubview:_replayCount];
        [_replayCount release];
        
        
    }
    
    return self;
    
}

- (void)layoutSubviews
{
    
    [super layoutSubviews];
    
    self.imagView.frame = CGRectMake(10, 10, 100, 100);
    
    CGFloat h = [[self class] heightWithText:_digestLabel.text];
     self.digestLabel.frame = CGRectMake(120, 50, 220, h);
    self.titleLabel.frame = CGRectMake(120, 10, self.contentView.frame.size.width - 130,40);
   
    self.replayCount.frame = CGRectMake(260, h + 50, 100, 40);
    
       
}

+(CGFloat)heightWithText:(NSString *)str
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake(220, 1000);
    CGRect rect = [str boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return rect.size.height;
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
